<template>
	<view class="uiwu">
		<view class="uiwu-list">
			<view class="uiwu-list-item uiwu-flex-space" v-for="(item,index) in listData" :key="index" @tap="openWindow(item)">
				<text class="name">{{item.title}}</text>
				<uiwu-icon type="arrowright" ></uiwu-icon>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { onLoad , onReachBottom } from '@dcloudio/uni-app'
	import { ref } from "vue";
	import { uiwu } from '@/config/config';
	import { problemlist } from '../../api/api';
	const listData = ref<Array<object>>([])
	const pageNum = ref<number>(1)
	const more = ref<string>('loading');
	const isLock = ref<boolean>(true)
	const openWindow = (item) => {
		uiwu.openWindow(`/pages/index/problemdetails?id=${item.id}`)
	}
	const getproblemlist = async (mack:boolean=false) : Promise<any> => {
		if(!mack) pageNum.value = 1
		const { data:{ data , total }} = await problemlist({
			page:pageNum.value,
		})
		isLock.value = true
		uiwu.setlist({
			isMore:mack,
			listData,
			total,
			listRow:data,
			more,
			pageNum
		})
	}
	onReachBottom(()=>{
		if(!isLock.value) return
		isLock.value = false
		pageNum.value++
		getproblemlist(true)
	})
	onLoad(()=>{
		getproblemlist()
	})
</script>

<style lang="scss">
	page{
		background-color: #F6F6F6;
	}
	.uiwu{
		padding: 20rpx 0;
	}
	.uiwu-list{
		padding: 0 24rpx;
		background-color: #fff;
		&-item{
			padding: 24rpx 0;
			border-bottom: 1rpx solid #E6E6E6;
			&:last-child{
				border-bottom: 0;
			}
			.name{
				font-size: 28rpx;
				font-weight: bold;
				color: #231815;
			}
		}
	}
</style>
